//
//  YDUserStatusViewCell.swift
//  weibo
//
//  Created by 孙亚东 on 16/6/27.
//  Copyright © 2016年 Sunyadong. All rights reserved.
//

import UIKit

class YDUserStatusViewCell: UITableViewCell {
    
    
    //定义一个model，重写set方法
    
    var model: YDUserViewModel? {
        
        didSet {
        
            originView.userViewModel = model
            footerView.userViewModel = model
            
            //首先应该判断
            reweetView.model = model
            
      
        }
    
    }
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        //添加控件
        
        setupUI()
        
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    func setupUI () {
    
        contentView.addSubview(originView)
        contentView.addSubview(footerView)
        contentView.addSubview(reweetView)
        
        contentView.backgroundColor = UIColor(white: 240.0 / 255, alpha: 1)

        //设置约束
        
        
        originView.snp_makeConstraints { (make) -> Void in
            
            make.left.right.equalTo(contentView)
            
            make.top.equalTo(contentView).offset(10)
            
            make.bottom.equalTo(reweetView.snp_top)
            
            
            
        }
        
        
        // 设置转发的frame
        
        reweetView.snp_makeConstraints { (make) -> Void in
            
            make.left.right.equalTo(contentView)
    
        }
        
    
        footerView.snp_makeConstraints { (make) -> Void in
            
            make.top.equalTo(reweetView.snp_bottom)
            
            make.right.left.equalTo(contentView)
   
            make.height.equalTo(44)
            
            
            
        }
        
        
        contentView.snp_makeConstraints { (make) -> Void in
            
            
            make.top.left.right.equalTo(self)
            make.bottom.equalTo(footerView.snp_bottom)
            
            
        }
        
        
    
    }
    
    
    
    //懒加载控件
    lazy var originView: YDOrigionView = {
    
        let originView = YDOrigionView()

         originView.backgroundColor = UIColor(white: 250.0 / 255, alpha: 1)
    
        
        return originView
    
    }()
    
    //懒加载 转发View
    
    lazy var reweetView: YDSweetView = {
    
        let reweetV = YDSweetView()

        return reweetV

    
    }()
   
    lazy var footerView: YDFooterView = {
    
    
        let footView = YDFooterView()

         footView.backgroundColor = UIColor(white: 250.0 / 255, alpha: 1)
        
        
        return footView
    

    }()
    
    
    
    

}
